package client.handler;

import client.Client;
import unit.response.*;

import java.util.HashMap;

/**
 * @author Innokenty
 * @since 08.08.11
 */
public class ResponseHandlerFactory {
    private HashMap<Class, ResponseHandler> requests;

    public ResponseHandlerFactory(Client client) {
        requests = new HashMap<Class, ResponseHandler>();

        requests.put(AddedToContactListMessage.class, new AddedToContactListMessageHandler(client));
        //requests.put(ContactInfoChangedMessage.class, new ContactInfoChangedMessageHandler(client));
        requests.put(CreateNewUserRequestResponse.class, new CreateNewUserResponseHandler(client));
        requests.put(GetContactListRequestResponse.class, new GetContactListResponseHandler(client));
        requests.put(LoginRequestResponse.class, new LoginResponseHandler(client));
        requests.put(SearchUserRequestResponse.class, new SearchUserResponseHandler(client));
//        requests.put(SearchUserRequestResponse.class, new SendMessageResponseHandler(client));
        requests.put(IncomingMessage.class, new IncomingMessageHandler(client));
    }

    public ResponseHandler getHandler(Class requestClass) {
        return requests.get(requestClass);
    }
}